package com.ruoyi.fly.service.impl;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.fly.domain.vo.StoreServerVo;
import com.ruoyi.fly.mapper.StoreServerMapper;
import com.ruoyi.fly.service.StoreServerService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StoreServerServiceImpl implements StoreServerService {

    @Autowired
    private StoreServerMapper storeServerMapper;

    /**
     * 新增店铺服务
     * @param storeServerVo
     * @return
     */
    @Override
    public R insertStoreServer(StoreServerVo storeServerVo) {
        storeServerVo.setCreateTime(DateUtils.getNowDate());
        storeServerVo.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return storeServerMapper.insertStoreServer(storeServerVo)>0?R.ok("新增成功"):R.fail("操作失败");
    }

    /**
     * 修改店铺服务
     * @param storeServerVo
     * @return
     */
    @Override
    public R updateStoreServer(StoreServerVo storeServerVo) {
        storeServerVo.setUpdateTime(DateUtils.getNowDate());
        storeServerVo.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        return storeServerMapper.updateStoreServer(storeServerVo)>0?R.ok("修改成功"):R.fail("操作失败");
    }

    /**
     * 删除店铺服务
     * @param id
     * @return
     */
    @Override
    public R deleteStoreServerById(String id) {
        return storeServerMapper.deleteStoreServerById(id)>0?R.ok("删除成功"):R.fail("操作失败");
    }

    @Override
    public R deleteStoreServerByIds(List<String> ids) {
        return storeServerMapper.deleteStoreServerByIds(ids)>0?R.ok("删除成功"):R.fail("操作失败");
    }
}
